package com.by.component.contract.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum ContractTypeEnum {

    CONTRACT(ContractTypeEnum.CONTRACT_CODE, "合同"),
    AGREEMENT(ContractTypeEnum.AGREEMENT_CODE, "协议"),
    ;

    private Integer code;
    private String desc;

    private static final Map<Integer, ContractTypeEnum> MAP = Arrays.stream(ContractTypeEnum.values())
            .collect(Collectors.toMap(ContractTypeEnum::getCode, Function.identity()));

    public static ContractTypeEnum resolve(Integer code) {
        return MAP.get(code);
    }

    public static final int CONTRACT_CODE = 1;
    public static final int AGREEMENT_CODE = 2;

}
